package com.gjs.intranet.service.impl;

import cn.hutool.core.util.EnumUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gjs.common.enums.entity.LibraryAttachFileTypeEnum;
import com.gjs.intranet.pojo.dto.LibraryAttachQueryDTO;
import com.gjs.intranet.pojo.entity.LibraryAttach;
import com.gjs.intranet.mapper.LibraryAttachMapper;
import com.gjs.intranet.service.ILibraryAttachService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 出版物附件表 服务实现类
 * </p>
 *
 * @author JC_Ho
 * @since 2022-04-11
 */
@Service
public class LibraryAttachServiceImpl extends ServiceImpl<LibraryAttachMapper, LibraryAttach> implements ILibraryAttachService {
    @Override
    public Wrapper<LibraryAttach> buildWrapper(LibraryAttachQueryDTO queryDTO){
        LambdaQueryWrapper<LibraryAttach> wrapper = new LambdaQueryWrapper<>();

        wrapper.eq(queryDTO.getId() != null && queryDTO.getId() > 0,LibraryAttach::getId,queryDTO.getId());
        wrapper.eq(queryDTO.getFileType() != null,LibraryAttach::getFileType,queryDTO.getFileType());
        wrapper.eq(queryDTO.getProjectId() != null && queryDTO.getProjectId() > 0,LibraryAttach::getProjectId,queryDTO.getProjectId());
        wrapper.eq(queryDTO.getBookId() != null && queryDTO.getBookId() > 0,LibraryAttach::getBookId,queryDTO.getBookId());

        return wrapper;
    }
}
